package com.gdufe.seckill.controller;

import com.gdufe.common.utils.PageUtils;
import com.gdufe.common.utils.R;
import com.gdufe.seckill.entity.RelationEntity;
import com.gdufe.seckill.service.RelationUserService;
import com.gdufe.seckill.vo.SeckilOrderFormVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

@RestController
@RequestMapping("seckill/relation/user")
public class RelationUserController {
    @Autowired
    private RelationUserService relationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = relationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		RelationEntity relation = relationService.getById(id);

        return R.ok().put("relation", relation);
    }

    /**
     * 秒杀商品表单初始化
     */
    @RequestMapping("/init/{id}")
    public R OrderForm(@PathVariable("id") Integer id){
        SeckilOrderFormVo vo = relationService.init(id);


        return R.ok().put("info", vo);
    }


}
